<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript" src="vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <style type="text/css">
        .form-control{
            width: 300px;

        }
        .maintop{
            margin: 0px 600px;
        }
        .bottomcanter{
            text-align: center;
        }



    </style>
</head>
<body style="background: linear-gradient(45deg,lightblue,lightgray);">
<div id="app">
<h1 style="text-align: center;">
    欢迎来到菜先生商家入驻中心
</h1>
<div style="width: 550px;height: 160px;margin: 0px 600px;">
    <h3>入驻须知</h3>
    <p>1.入驻店铺需要实名制认证</p>
    <p>2.要根据公司的规章制度来经营自己的店铺</p>
    <p>3.要遵纪守法</p>
    <p>请仔细阅读后点击下方同意按钮才可以入驻成为商家</p>
    <p>如果您同意，请点击下面的按钮以接受我们的服务</p>
    <div style="margin: 0 auto">
    <el-radio v-model="radio" :value="1" label="1">同意</el-radio>
    <el-radio v-model="radio" :value="2" label="2">不同意</el-radio>
    </div>
</div>

<form id="bar">
    <div style="text-align: center;margin-top: 100px;"><h1>注册商家</h1></div>
    <div class="maintop">
        <div class="form-group">
            <label>身份证号：</label>
            <input type="text" class="form-control" name="idcard" placeholder="请输入身份证号:" id="idcard">
        </div>

        <div class="form-group">
            <label >姓名：</label>
            <input type="text" class="form-control" name="bname" placeholder="请输入姓名：" id="bname" >
        </div>
    </div>
</form>
<div class="bottomcanter">
    <button id="submitIDCard" class="btn btn-primary">提交</button>
    <button type="reset" class="btn btn-default" id="reset">重置</button>
    <button  class="btn btn-default" id="goback">返回首页</button>
</div>
</div>
<script type="text/javascript">
    var app = new Vue({
        el:"#app",
        data:{
            radio:"1",
        },
        methods:{}
    });
    submitIDCard.onclick=function () {
        var idcardData=new FormData(bar);
        $.ajax({
            url: "/cai/businessRegister/certification",
            type: "POST",
            data: idcardData,
            processData: false,
            contentType: false,
            success: function(data) {
                    if (app.radio == 1){
                        if(data.message!='成功') {
                            alert(data.message);
                        }
                        alert(data.result.description);
                        if(data.code==0 && data.result.description=='一致'){
                            $.ajax({
                                url: "/cai/businessRegister/addInfo",
                                type: "POST",
                                data: idcardData,
                                processData: false,
                                contentType: false,
                                success: function(backData) {
                                    alert(backData.msg);
                                    if(backData.code==1){
                                        window.location.href="/cai/userLogin.html";
                                    }
                                }
                            });
                        }
                        // else{
                        //     alert("请先同意协议才可以入驻");
                        // }
                    }
                    else {
                        app.$notify.error({
                            title: '错误',
                            message: '请先同意协议才可以入驻'
                        });
                    }
               }
        });
    };

    reset.onclick=function (){
        idcard.value="";
        bname.value="";

    };
    goback.onclick=function () {
        window.location.href="/cai/indexTwo.html";
    }

</script>
</body>
</html>